package com.qf.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.mapper.UserMapper;
import com.qf.pojo.User;
import com.qf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("findAll")
    public List<User> findAll(){
        System.out.println("findall   beichufa");
        return userService.list();
    }

    @RequestMapping("/login")
    public boolean login(User user){
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("userName",user.getUserName());
        queryWrapper.eq("password",user.getPassword());
        User user1 = userService.getOne(queryWrapper);
        if (user1 != null){
            return true;
        }
        else {
            return false;
        }
    }

}
